<template>
  <a-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭"
  >
    <a-spin :spinning="confirmLoading">
      <a-form-model :model="model" :form="form" :rules="rules" ref="form" layout="vertical">
        <a-row class="form-row" :gutter="16">
          <a-col :span="6">
            <a-form-model-item label="品种" prop="column1">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="品种类别" prop="column2">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="支数" prop="column3">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="挡车机台系数" prop="column4">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
      <a-form-model :model="model" :form="form" :rules="rules" ref="form" layout="vertical">
        <a-row class="form-row" :gutter="16">
          <a-col :span="6">
            <a-form-model-item label="挡车品种系数" prop="column1">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="挡车单价系数" prop="column2">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="挡车综合系数" prop="column3">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="落纱机台系数" prop="column4">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
      <a-form-model :model="model" :form="form" :rules="rules" ref="form" layout="vertical">
        <a-row class="form-row" :gutter="16">
          <a-col :span="6">
            <a-form-model-item label="落纱品种系数" prop="column1">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="落纱单价系数" prop="column2">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="落纱综合系数" prop="column3">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="锭数" prop="column4">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
      <a-form-model :model="model" :form="form" :rules="rules" ref="form" layout="vertical">
        <a-row class="form-row" :gutter="16">
          <a-col :span="6">
            <a-form-model-item label="定量" prop="column1">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="8小时定额长度" prop="column2">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="挡车单价（百米/元）" prop="column3">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="落纱单价（元/落）" prop="column4">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
      <a-form-model :model="model" :form="form" :rules="rules" ref="form" layout="vertical">
        <a-row class="form-row" :gutter="16">
          <a-col :span="6">
            <a-form-model-item label="换纱单价（元/落）" prop="column1">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="落纱清洁单价（元/台）" prop="column2">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="落纱产量单价（元/台）" prop="column3">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="摆管单价（元/台）" prop="column4">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
      <a-form-model :model="model" :form="form" :rules="rules" ref="form" layout="vertical">
        <a-row class="form-row" :gutter="16">
          <a-col :span="6">
            <a-form-model-item label="台数" prop="column1">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="8小时台数" prop="column2">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="挡车定额看台（台）" prop="column3">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="落纱定额看台（台）" prop="column4">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
      <a-form-model :model="model" :form="form" :rules="rules" ref="form" layout="vertical">
        <a-row class="form-row" :gutter="16">
          <a-col :span="6">
            <a-form-model-item label="推粗纱台位单价（台/元）" prop="column2">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="推粗纱落纱单价（落/元）" prop="column3">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="推粗纱挂纱、收管单价（落/元）" prop="column4">
              <a-input placeholder="请输入" v-model="model.column1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-spin>
  </a-modal>
</template>

<script>
import { httpAction } from '@/api/manage'
import JEditor from '@/components/jeecg/JEditor'
import JSwitch from '@/components/jeecg/JSwitch'
export default {
  name: 'XiShaPinZhongGongDingCanShuModal',

  components: {
    JEditor,
    JSwitch,
  },
  data() {
    return {
      title: '操作',
      visible: false,
      disable: true,
      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      confirmLoading: false,
      form: this.$form.createForm(this),
      rules: {},
      url: {
        //   add: '/crm_device/crmDevice/add',
        //   edit: '/crm_device/crmDevice/edit',
      },
    }
  },
  created() {},
  methods: {
    add() {
      this.disable = false
      this.model = Object.assign({}, {})
      this.edit({}, 1)
    },
    edit(record, isEdit) {
      if (isEdit != 1) {
        this.model = Object.assign({}, record)
      }

      this.visible = true
    },
    close() {
      this.$emit('close')
      this.visible = false
      this.disable = true
      this.$refs.form.resetFields();
    },

    handleOk() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.confirmLoading = true
          let httpurl = ''
          let method = ''
          if (!this.model.id) {
            httpurl += this.url.add
            method = 'post'
          } else {
            httpurl += this.url.edit
            method = 'put'
          }
          let formData = Object.assign(this.model)
          console.log('formData', formData)
          //时间格式化
          httpAction(httpurl, formData, method)
            .then((res) => {
              if (res.success) {
                this.$message.success(res.message)
                this.$emit('ok')
              } else {
                this.$message.warning(res.message)
              }
            })
            .finally(() => {
              this.confirmLoading = false
              this.close()
            })
        } else {
          return false
        }
      })
    },

    handleCancel() {
      this.close()
    },
  },
}
</script>

<style scoped></style>
